import QtQuick 2.6
import QtQuick.Controls 2.4

Popup{
    id:waitdialog
    modal: true
    width: parent.width/3
    height: 350
    x:(parent.width-width)/2
    y:(parent.height-height)/2
    focus: true
    closePolicy: Popup.CloseOnEscape
    property string name:""

    function updateEmcy(tx){
        name = tx
        mtext.text = name
    }

    Component.onCompleted: {
        mtext.text = name
    }

    Rectangle{
        anchors.fill: parent
        color: "#00000000"
        AnimatedImage {
            id: animated
            anchors.left: parent.left
            anchors.leftMargin: (parent.width-width)/2
            anchors.top: parent.top
            anchors.topMargin: (parent.height-height-mtext.height-25)/2
            source: "qrc:/shared/waiting.gif"
            onCurrentFrameChanged: {
                if(currentFrame==frameCount-1){
                    if(mtext.text.length-name.length>4)
                        mtext.text = name
                    else
                        mtext.text+= " ."
                }
            }
        }

        Text{
            id:mtext
            anchors.top: animated.bottom
            anchors.topMargin: 30
            anchors.left: parent.left
            anchors.leftMargin: (parent.width-(name.length+3)*20)/2
            anchors.right: parent.right
            height: 50
            horizontalAlignment: Text.AlignLeft
            verticalAlignment: Text.AlignVCenter
            font.pixelSize: 27
        }
    }
}

